#!/usr/bin/python
# -*- coding: UTF-8 -*-

from extension.test_logic.DpuLogic import DpuLogic


class DPU2_FUNCTION_027(DpuLogic):
    """
        Name:
            DPU2_FUNCTION_028
        Label:
           OS下执行ipmitool power soft
        PreCondition:

        TestStep:
            OS下执行ipmitool power soft
        ExpectedResult:
            A) 1.服务器进入S5或FS5状态，智能网卡不掉电
                2.ping网卡系统端口可以正常ping通
        Parameters:

        Author:
            HK1342
        Last Modified:
            2025/05/09
        Remark:

    """

    # 测试执行前配置等准备操作
    def pre_test_case(self):
        super().pre_test_case()

    # 测试步骤
    def procedure(self):
        self.log_step("Step1: ipmitool power soft")
        self.dpu_ipmi.set_chassis_power_status("soft")

        self.log_step("Step2: 查询智能网卡不下电")
        self.ping_until_reachable(self.dpu_host.local_ip, timeout=10)

    def post_test_case(self):
        self.ping_until_reachable(self.os_host.local_ip, timeout=600)  # 等待系统OS上电
